Method and apparatus for controlling robots

ABSTRACT

A method and apparatus for controlling a robot is provided. In this robot, direct teaching can be performed while updating a position command on the basis of an applied external force. In the method and apparatus, a proximity region is set inside a boundary of an operation-allowed range of the robot, the proximity region being indicative of a proximity of the boundary. Stored is an external force applied when a monitoring point provided in the robot reaches the proximity region as a reference external force. And performed is comparing the reference external force with a current external force when a current position of the monitoring point is in the proximity region, to thereby determine a direction that facilitates movement away from the proximity region.

CROSS-REFERENCE TO RELATED APPLICATION

This application is based on and claims the benefit of priority fromearlier Japanese Patent Application No. 2018-181640 filed Sep. 27, 2018,the description of which is incorporated herein by reference.

BACKGROUND Technical Field

The present invention relates to a method and an apparatus forcontrolling a robot, such as an industrial robot, to which directteaching is applicable.

Related Art

In recent years, direct teaching has been adopted as a teaching methodfor industrial robots, in which an operator teaches the robot bydirectly operating the robot arm while, in the robot, updating theposition command is carried out based on an applied external force givenby the direct teaching. A publication of JP-H08-216074 A is an exampleof the related art.

PATENT REFERENCE

[Patent Reference 1] JP-H08-216074 A

In such direct teaching, position control is performed, by which theposition command is updated on the basis of the magnitude and directionof the applied external force. For example, the position command for theend effector position is updated basically on the basis of the directionand magnitude of the applied external force. If the robot deviates fromthe operation-allowed range during teaching, there is a risk that anexcessive load may be applied to the robot arm or the robot arm may comeinto contact with peripheral devices. Accordingly, in order to preventoperation errors, the movement relative to the applied external force isrelatively reduced, that is, the feel of moving the robot is madeheavier so that the operator can recognize that an operation-prohibitedrange is being approached.

However, if the feel is controlled to become heavy when the boundary ofthe operation-allowed range is approached, the feel is always heavy in aproximity region of the boundary of the operation-allowed range.Accordingly, the feel remains heavy even if the arm moves in an escapedirection, that is, a direction moving away from the proximity of theoperation-prohibited range. This causes problems that the usability inthe proximity region is reduced and moving away from the proximityregion becomes difficult.

Further, when the arm reaches the boundary of the operation-allowedrange, the robot is stopped as an error. However, in resuming the directteaching, it is necessary to move the stopped arm into theoperation-allowed range by using another control device. Accordingly,the user is forced to perform complicated operations each time when thearm reaches the operation-prohibited range during direct teaching.

In collaborative robots, which allow operators and robots to worktogether without providing safety guards such as fences around therobot, the operation-allowed range tends to be smaller than that of theconventional industrial robots. For example, the range of motion of thearticulation is reduced compared to that of the conventional generalindustrial robots for safety reasons, or taking a specific posture isprohibited. Accordingly, it is assumed that there are many situationswhere it is necessary to move the arm at the proximity of the boundaryof the operation-allowed range or to move the arm away from theproximity of the boundary during direct teaching. Therefore, ease ofmoving away from the proximity of the operation-prohibited range is alsodemanded.

SUMMARY

It is thus desired to provide a method and an apparatus for controllingan industrial robot with improved usability in direct teaching.

According to an exemplary embodiment of the disclosure, a method andapparatus for controlling a robot such as an industrial robot, in whichdirect teaching is performed while updating a position command on abasis of an applied external force, the method includes: setting aproximity region inside a boundary of an operation-allowed range(simply, an operating range) of the robot, the proximity region beingindicative of a proximity of the boundary; storing an external forceapplied when a monitoring point provided in the robot reaches theproximity region as a reference external force; and comparing thereference external force with a current external force when a currentposition of the monitoring point is in the proximity region to therebydetermine a direction that facilitates movement away from the proximityregion.

This method structure can also be provided as an apparatus forcontrolling a robot as another mode.

In direct teaching, an operator changes the posture of the robot bytouching the arm or other part of the robot. Since the posture of therobot can be recognized by the controller, the current position of themonitoring point provided in the robot can be specified from the currentposture of the robot. Further, in the configuration for direct teaching,since an external force can be detected by using a sensing device suchas a force sensor or a torque sensor, a direction and a magnitude of theapplied external force can also be specified.

In order to prevent reaching an operation-prohibited range (simply anoutside range of the operating range) during direct teaching, it iseffective to limit movement in the proximity region. On the other hand,if movement in the proximity region is completely restricted, movementin a direction away from the proximity region is also restricted, whichaffects the usability. Therefore, in restricting theoperation-prohibited range from being reached, it is desirable tofacilitate movement in a direction away from the proximity region.Although a range that the arm of the robot can reach is set as theoperation-allowed range, the operation-allowed range may not necessarilybe a maximum range, but may be a range that does not interfere withperipheral devices. Therefore, when attempting to move away from theboundary closest to a current position, the arm may approach anotherboundary. That is, in order to facilitate movement away from theproximity of the operation-prohibited range, it is important todetermine in which direction moving out of the operation-allowed rangecan be prevented, that is, which direction can be used as a reference.

Therefore, an external force applied when the monitoring point reachesthe proximity region is stored as a reference external force. Then, thereference external force is compared with the current external forcewhen the current position of the monitoring point is in the proximityregion to thereby determine a direction that facilitates movement awayfrom the proximity region. Accordingly, whether the current movementdirection is a direction that should be restricted or not can bedetermined.

Further, the direction of the external force when the monitoring pointreaches the proximity region is a direction in which the monitoringpoint has so far moved. Accordingly, the movement direction indicates apath along which the monitoring position has so far moved, that is, adirection not to meet obstacles when moving away from the proximityregion. Therefore, when moving away from the proximity region, that is,the proximity of the operation-prohibited range is desired, a directionof the external force at the time of reaching the proximity region canbe used as a reference to specify a direction that does not interferewith peripheral devices. Accordingly, a direction that is opposite tothe external force at the time of reaching can be determined orspecified as a direction that facilitates movement away from theproximity region.

Thus, in determining the direction that facilitates movement away fromthe proximity region, it is possible to determine whether the currentmovement direction is a direction that should be restricted or not, andto specify a direction that facilitates exiting by using the directionof the external force at the time of reaching the proximity region as areference. Therefore, control can be performed, for example, to restrictmovement in the direction toward the operation-prohibited range, andpermit movement in the direction that facilitates exiting to therebyimprove usability during direct teaching.

According to another exemplary embodiment of the disclosure, a methodfor controlling a robot, in which direct teaching is performed whileupdating a position command on a basis of an applied external force, themethod includes: setting a proximity region inside a boundary of anoperation-allowed range of the robot, the proximity region beingindicative of a proximity of the boundary; setting a virtual externalforce toward the operation-prohibited range starting from a currentposition as a reference external force on a basis of a shape of aboundary which is closest to a current position or a distance to theboundary; and comparing the reference external force with a currentexternal force when the current position of the monitoring point is inthe proximity region to thereby determine a direction that facilitatesmovement away from the proximity region.

While the proximity region is in the proximity of theoperation-prohibited range, there may be a case where it is necessary tochange the posture of the robot, that is, to move the monitoring pointin the proximity region. As the current position changes in theproximity region, the direction toward the operation-prohibited rangefrom the current position, in other words, the direction in whichexiting the proximity region is easy, may also change.

Therefore, a virtual external force toward the operation-prohibitedrange starting from the current position is set as a reference externalforce on the basis of the shape of the boundary which is closest to thecurrent position, or the distance to the boundary. The referenceexternal force is compared with the current external force to therebydetermine a direction that facilitates movement away from the proximityregion. In this case, in order to determine whether the direction isdirected to the operation-prohibited range or not, the direction of thereference external force is of importance, and the magnitude thereof isnot so important. Therefore, for example, for the magnitude of thereference external force, a reference value can be set in advance or themagnitude of the current external force can be used for convenience.

Thus, a direction toward the closest boundary, starting from the currentposition, is set as a direction toward the operation-prohibited range.On the basis of the reference external force directed in this direction,the direction that facilitates exiting from the proximity region can bedetermined to thereby specify whether the current movement direction isa direction that should be restricted or not, and specify a directionthat facilitates exiting.

Alternatively, in the case where the closest boundary is formed by aflat surface such as a wall, a direction vertical to the flat surface,starting from the current position, is set as a direction toward theoperation-prohibited range. On the basis of the reference external forcedirected in this direction, the direction that facilitates exiting fromthe proximity region can be determined to thereby specify whether thecurrent movement direction is a direction that should be restricted ornot, and specify a direction that facilitates exiting.

Therefore, control can be performed, for example, to restrict movementin the direction toward the operation-prohibited range, and permitmovement in the direction that facilitates exiting to thereby improveusability during direct teaching.

According to another exemplary embodiment of the disclosure, a methodfor controlling a robot, in which direct teaching is performed whileupdating a position command on a basis of an applied external force, themethod includes: setting a proximity region inside a boundary of anoperation-allowed range of the robot, the proximity region beingindicative of a proximity of the boundary; setting a virtual externalforce, starting from a current position of a monitoring point providedin the robot, in a direction from an origin of the robot toward thecurrent position as a reference external force; and comparing thereference external force with a current external force when a currentposition of the monitoring point is in the proximity region to therebydetermine a direction that facilitates movement away from the proximityregion.

The operation-allowed range may be set as a range that the arm of therobot can reach. Therefore, a situation can be assumed where the robotarm is fully extended at the boundary of the operation-allowed range. Inother words, the direction in which the robot arm is retracted can beregarded as the direction in which it exits the operation-prohibitedrange. For example, if the robot arm has a reach limit, the directiontoward the origin of the robot is taken as the direction in which thearm is retracted, which is the direction in which exiting is easiest.

Therefore, a virtual external force, starting from the current position,in the direction from the origin toward the current position is set as areference external force. The reference external force is compared withthe current external force to thereby determine a direction thatfacilitates movement away from the proximity region. In this case, forthe magnitude of the reference external force, a reference value can beset in advance or the magnitude of the current external force can beused for convenience as described above.

Thus, on the basis of the reference external force directed in thedirection from the origin toward the current position, starting from thecurrent position, the direction that facilitates exiting from theproximity region can be determined to thereby specify whether thecurrent movement direction is a direction that should be restricted ornot, and specify a direction that facilitates exiting. Therefore,control can be performed, for example, to restrict movement in thedirection toward the operation-prohibited range, and permit movement inthe direction that facilitates exiting to thereby improve usabilityduring direct teaching.

According to another exemplary embodiment of the disclosure, a methodfor controlling a robot, in which direct teaching is performed whileupdating a position command on a basis of an applied external force, themethod includes: setting a proximity region inside a boundary of anoperation-allowed range of the robot, the proximity region beingindicative of a proximity of the boundary; setting a position closest tothe boundary, among virtual positions displaced from a current positionof a monitoring point provided in the robot by a predetermined distance,as a closest approach position; setting a virtual external force,starting from a current position of the monitoring point, in a directionfrom the current position toward the closest approach position as areference external force; and comparing the reference external forcewith a current external force when the current position of themonitoring point is in the proximity region to thereby determine adirection that facilitates movement away from the proximity region.

While the proximity region is in the proximity of theoperation-prohibited range, there may be a case where it is necessary tochange the posture of the robot, that is, to move the monitoring pointin the proximity region. As the current position changes in theproximity region, the direction toward the operation-prohibited rangefrom the current position, in other words, the direction in whichexiting the proximity region is easy, may also change.

Therefore, plurality of virtual positions displaced from the currentposition by a predetermined distance are obtained by calculation, and avirtual external force, starting from the current position, in thedirection toward the closest approach position is set as a referenceexternal force. The reference external force is compared with thecurrent external force to thereby determine a direction that facilitatesmovement away from the proximity region. In this case, for the magnitudeof the reference external force, a reference value can be set in advanceor the magnitude of the current external force can be used forconvenience as described above.

Thus, the virtual closest approach position closest to the boundary isset, and on the basis of the reference external force, starting from thecurrent position, in the direction toward the closest approach position,the direction that facilitates exiting from the proximity region can bedetermined to thereby specify whether the current movement direction isa direction that should be restricted or not, and specify a directionthat facilitates exiting. Therefore, control can be performed, forexample, to restrict movement in the direction toward theoperation-prohibited range, and permit movement in the direction thatfacilitates exiting to thereby improve usability during direct teaching.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic view of a configuration of a robot according to afirst embodiment.

FIG. 2 is a schematic view exemplifying an operation-allowed range of arobot arm.

FIG. 3 is a flowchart showing a reduction in an external force which isapplied to the robot arm.

FIG. 4 is a schematic view illustrating an example of a state of amonitoring point which has reached a proximity region.

FIG. 5 is a diagram illustrating a reduction pattern A on which areduction coefficient is calculated.

FIG. 6 is a diagram illustrating a reduction pattern B on which areduction coefficient is calculated.

FIG. 7 is a diagram illustrating a reduction pattern C on which areduction coefficient is calculated.

FIG. 8 is a diagram illustrating a reduction pattern D on which areduction coefficient is calculated.

FIG. 9 is a diagram illustrating a reduction pattern E on which areduction coefficient is calculated.

FIG. 10 is a diagram illustrating a reduction pattern F on which areduction coefficient is calculated.

FIG. 11 is a diagram schematically illustrating a mode for determining adirection according to a second embodiment.

FIG. 12 is a diagram schematically illustrating a mode for determining adirection according to a third embodiment.

FIG. 13 is a diagram schematically illustrating a mode for determining adirection according to a fourth embodiment.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

With reference to the drawings, a plurality of embodiments will bedescribed. Throughout the embodiments, the same reference numerals areused to refer to substantially the same components.

First Embodiment

Referring to FIGS. 1 to 10, a first embodiment will now be described. Asshown in FIG. 1, an industrial robot 1 of the present embodiment is avertically articulated six-axis robot having a plurality of arms, and iscontrolled by a controller 2 serving as a robot control apparatuscapable of performing control methods according to the presentdisclosure. In the present embodiment, the robot 1 is assumed to be acollaborative robot (which is an industrial robot), which is installednear the operator's workplace without need of providing a safety guardsuch as a fence around the robot to work cooperating with the operator.

The robot 1 includes a shoulder 1 b connected to a base 1 a via a firstaxis (joint: 31), a lower arm 1 c connected to the shoulder 1 b via asecond axis (joint: 32), a first upper arm 1 d connected to the lowerarm 1 c via a third axis (joint: 33), a second upper arm 1 e connectedto the first upper arm 1 d via a fourth axis (joint: 34), a wrist 1 fconnected offset from the second upper arm 1 e via a fifth axis (joint:35), and a flange 1 g connected to the wrist 1 f via a sixth axis(joint: 36).

In the present embodiment and its modifications, a center position ofthe flange 1 g in the space is set as a monitoring point (P) formonitoring a change in posture of the robot 1. Assuming a threedimensional coordinate system having an X axis and a Y axis parallelwith an installation surface and a Z axis vertical to the installationsurface with the center of the base 1 a of the robot 1 as an origin (O),the monitoring point (P) can be obtained by a six-dimensional Cartesiancoordinate system represented by coordinates (Px, Py, Pz) thereof androtation components (Rx, Ry, Rz) of the flange 1 g.

Further, an external force, which is a force given to the robot from theoutside by an operator during the direct teaching, is applied to themonitoring point (P) of the robot 1 can be obtained by thesix-dimensional Cartesian coordinate system represented by magnitudecomponents (Fx, Fy, Fz) in each direction and the moment (Mx, My, Mz) inthe three-dimensional coordinate system. In the present embodiment,since the monitoring point (P) of the robot 1 is specified by a positionof the flange 1 g, that is, a robot-arm distal end portion, it isconventionally referred to as an end force. However, this end force doesnot necessarily only refer to an external force applied to the distalend portion of the robot 1, but also refer to a current external forceapplied to the monitoring point (P) of the robot 1.

The robot 1, in which a work tool 3 (i.e., end effector) is attached tothe flange 1 g, operates while the posture of the robot 1 is controlledby the controller 2. As known in the art, the controller 2 controls therobot 1 to a desired posture by rotating an electric motor M provided ateach of the articulations (joints) of the robot 1, in accordance withinformation from each of rotational position sensors arranged in thearticulations. Hence, the end effector attached to the distal and of therobot arm can take any posture (i.e., any commanded three-dimensionalposition and direction).

The controller 2 is configured to detect an external force applied tothe robot 1 by using a sensing device such as a force sensor R or atorque sensor T provided in the articulations (joints) of the arm of therobot 1, and also to perform direct teaching, in which the operatorteaches the operation position by changing the posture (i.e., a positionand a direction of the end effector attached to the arm distal end) andby directly touching the arm or the end effector of the robot 1. In eachof the articulations (joints) of the arm of the robot 1, a rotationalposition sensor (not shown) is also arranged to detect a rotationalposition of each of the articulations. In the robot 1 shown in FIG. 5,the sensors are illustrated as a representative only at one joint toshow rough positions thereof, although such sensors are actuallyprovided at all the joints of the robot 1.

By way of example, the controller 2 is provided as a computer system andconfigured to perform in sequence steps composing a preset controlprogram which includes control of the external force according to thepresent embodiment. A practical example is shown in FIG. 1, in which thecontroller 2 is provided with a central processing unit (CPU) 2A, aread-only memory (ROM; such as EEPROM) 2B, a random access memory (RAM)2C, which are communicably connected to each other via an internal bus2D. This internal bus 2D is also connected to the sensors and motors viaan interface 2E. The CPU 2A functions as functional control means, whilethe ROM 2B is provided to function as non-transitory computer-readablerecording medium in which steps of preset various control programs arestored as source codes in advance. Such programs are read by the CPU 2Ainto a preset work area in a main memory provided by for example the RAM2C, with the program steps executed. The RAM 2C is provided as a memorydevice in which various data processed by the CPU 2A are temporarily. Ofcourse, the foregoing structure of the computer system is just oneexample, any type of computer systems can be adopted as long as presetcontrol programs can be executed. For example, a plurality of CPUs canbe provided for decentralized control or for redundant computer systems.The CPU 2A is a main device for calculation carried out in this computersystem, so that, provided that the same kind of functions as those ofthe CPU 2A is secured, main devices having other device names (such as aprocessor) can be adopted.

Further, although the details will be described later, the controller 2(i.e., the CPU 2A) executes a procedure for reducing the external forceaccording to a movement direction of the monitoring point (P) of therobot 1. The reduction in the external force is for providing theoperator with a heavier operating feeling when the operator manuallymoves the arm for the directing teaching. In other words, according tothe present embodiment, the controller that controls the robot 1executes a procedure for reducing an external force (see FIG. 3).

Next, an effect of the above configuration will be described. In therobot 1, an operation-allowed range (simply an operating range) ispreset in the operating space as a range that the arm is physicallyreachable or a range for preventing the arm from touching surroundingstructures. For example, as shown in FIG. 2 in a plan view, theoperation-allowed range (the operating range) is set on the basis of adistance from the origin (O). The range from the origin (O) to aboundary line (Lb), which is set at a predetermined distance from theorigin (O) (hereinafter, referred to as inside), including the boundaryline (Lb), is set as an operation-allowed range, and the range outsidethe boundary line (Lb) (hereinafter, referred to as outside) is set asan operation-prohibited range (simply an outside range of the operatingrange). That is, the boundary line (Lb) represents a boundary of theoperation-allowed range. The operation-allowed range can also be set forposition and/or posture of the robot that are desired to be prohibiteddue to the configuration and operating environment of the robot, such asangle limit, a singular point, and/or a reach limit of each of thearticulations.

Further, in the present embodiment, an inner boundary line (Lc) is setat a position inside the boundary line (Lb) spaced by a predetermineddistance difference (ΔL). A range between the boundary line (Lb) and theinner boundary line (Lb), that is, a range obtained by reducing andapproximating the operation-allowed range is a proximity region (R) setnear and inside the boundary line (Lb). In FIG. 2, the operation-allowedrange is shown in a plan view. However, when the monitoring point (P) ofthe robot 1 moves in the vertical direction as well, theoperation-allowed range and the proximity region (R) are threedimensional ranges. Further, the proximity region (R) may also be setincluding the boundary line (Lb) as long as it does not exceed theboundary line (Lb).

As described above, in direct teaching, an external force required tomove the robot can be increased according to the degree of approach tothe operation-prohibited range (the outside range of the operatingrange), that is, the feel when moving the robot can be made heavier toprevent the robot from intruding the operation-prohibited range, leadingto improved usability.

However, in this case, the feel is always heavy in the proximity of theboundary of the operation-allowed range. Accordingly, the feel remainsheavy even if the arm is moved in an escape direction, that is, adirection moving away from the proximity of the operation-prohibitedrange, leading to reduction in usability. Further, while the robot needsto be stopped in order to prevent the arm from reaching theoperation-prohibited range, it is necessary to move the arm into insidethe operation-allowed range by using another control device to resumethe direct teaching. Accordingly, the user is forced to performcomplicated operations each time when the arm reaches theoperation-prohibited range.

In the case of collaborative robots such as the robot 1, theoperation-allowed range tends to be smaller. For example, the range ofmotion of the articulation is reduced for safety reasons, or taking aspecific posture is prohibited. Accordingly, it is assumed that thereare many situations where it is necessary to move the arm at theproximity of the operation-prohibited range or to move the arm so as toexit the boundary of the operation-allowed range during direct teaching.

In the present embodiment, the controller 2 executes the procedure shownin FIG. 3. In short, this procedure is performed for adjusting anexternal force, which is, in the present embodiment, an end force whichshould be applied to the arm end, which is required to move themonitoring point (P) of the robot 1 according to the direction.

Specifically, upon starting the direct teaching, the controller 2 (i.e.,CPU 2A) executes, in parallel with the processing for the directteaching, the procedure to obtain a current end force (Fcur) (step S1),calculate a current position of the current monitoring point (P) basedon the rotation angle or the arm or the like (step 2), and determinewhether the current position of the monitoring point (P) is located inthe operation-allowed range and inside the proximity region, that is, ona side of the proximity region (R) closer to the origin (O) (step S3).

If the current position is determined as being inside the proximityregion (step S3: YES), the controller 2 turns off a proximity flag(incFlag) and sets it to 0 (step S4). The proximity flag (incFlag) isturned on and set to 1 when the monitoring point (P) reaches theproximity region (R), and is turned off and set to 0 when the monitoringpoint (P) exits the proximity region (R). After turning off theproximity flag (incFlag), the controller 2 sets a reduction coefficient(α), which indicates the degree of reduction of end force, to 1 (stepS5). The reduction coefficient (α), which will be detailed later, is anumerical value ranging from 0 to 1, and indicates the degree to whichthe external force is reduced. The reduction coefficient (α)=1 in stepS5 means that the external force is not reduced.

Then, the controller 2 calculates a converted end force (CFcur) bymultiplying the end force (Fcur) by the reduction coefficient (α) (stepS6), and updates the position command in the direction of the convertedend force (CFcur) (step S7). That is, the controller 2 adjusts themagnitude of the external force required to move the monitoring point(P) by multiplying the reduction coefficient (α) to the applied endforce (Fcur). However, if the current position is located inside theproximity region, α=1, that is, the end force is controlled so as not tobe reduced. As the value of the converted end force (CFcur) increases,the external force required for movement decreases, whereas, as thevalue decreases, the required external force increases.

When the arm moves and the monitoring point (P) reaches the proximityregion (R), which is for example shown in FIG. 4 as “proximity region isreached,” the current position of the monitoring point (P) is not insidethe proximity region any more (step S3: NO). Then, the controller 2determines whether the proximity flag (incFlag) is 1 (step S8). In FIG.4, the dotted arrow S indicates the current movement direction of themonitoring point (P).

Subsequently, since the flag (incFlag) is 0 (step S8: NO) when the armfirst reaches the proximity region (R), the controller 2 turns on theproximity flag (incFlag) and sets it to 1 (step S9), and then stores theend force (Fcur) at the time of reaching the proximity region (R) as anend force in reaching (Finc), which is obtained by the six dimensionalCartesian coordinate system (step S10). The end force in reaching (Finc)corresponds to a reference external force in the present embodiment.

Then, the controller 2 calculates a degree of ease of exit (e) byobtaining an inner product of the current end force (Fcur) and aninverse end force (−Finc), which is an inverse end force in reaching(Finc) (step S11). That is, the degree of ease of exit (e) is a valueobtained as an inner product value of a vector of the current externalforce and an inverse vector of the reference external force. The degreeof ease of exit (e), in simple terms, is a parameter for adjusting themagnitude of the force required to move the monitoring point (P), and isused for control when the monitoring point (P) is located in theproximity region (R). In addition, the inner product may also beobtained only by the components of the three-dimensional coordinatesystem, excluding the rotation component. The same applies to otherembodiments.

When the monitoring point (P) moves in the same direction as the endforce in reaching (Finc), the direction is regarded as a directiontoward the operation-prohibited range. On the other hand, when themonitoring point (P) moves in a direction opposite to the end force inreaching (Finc), the direction is regarded as a direction moving awayfrom the proximity of the operation-prohibited range. Therefore, in theproximity region (R), movement in the direction of the end force inreaching (Finc) should be suppressed in order to prevent movement towardthe operation-prohibited range.

On the other hand, movement in a direction opposite to the end force inreaching (Finc) does not need to be suppressed in order to facilitateexiting the proximity of the operation-prohibited range. In addition, bydecreasing the external force required to move in the direction awayfrom the boundary line (Lb) of the operation-allowed range relative tothe external force required to move toward the operation-prohibitedrange, the direction to move becomes tactile and intuitivelyrecognizable. Accordingly, it is possible to smoothly move away from theproximity of the operation-prohibited range.

For this reason, the controller 2 calculates the degree of ease of exit(e) by obtaining an inner product of the current end force (Fcur) and aninverse end force (−Finc), which is an inverse end force in reaching(Finc). The degree of ease of exit (e) calculated by obtaining the innerproduct approaches 1 in the direction that facilitates exiting, that is,the direction opposite to that at the time of reaching, whereas itapproaches −1 in the direction that restricts exiting or makes exitingdifficult, that is, the direction which is the same as that at the timeof reaching. More specifically, when equal to 0, the degree of ease ofexit (e) indicates a direction vertical to the end force in reaching(Finc). When larger than 0, it indicates a direction moving away fromthe operation-prohibited range. When smaller than 0, it indicates adirection moving toward the operation-prohibited range.

In other words, whether the movement direction of the monitoring point(P) is a direction moving toward the operation-prohibited range can bedetermined depending on whether the degree of ease of exit (e) is 0,positive, or negative. Accordingly, the controller 2 calculates thedegree of ease of exit (e) in step S10 to thereby determine whether themovement direction of the monitoring point (P) is a direction movingtoward the operation-prohibited range. The end force (Fcur) and the endforce in reaching (Finc) are equal when the arm first reaches theproximity region.

After calculating the degree of ease of exit (e), the controller 2calculates the reduction coefficient (α) (step S12). As described above,the reduction coefficient (α) is a numerical value ranging from 0 to 1,and indicates the degree to which the external force is reduced bymultiplying the current end force (Fcur). More specifically, when thereduction coefficient (α)=1, the external force is not reduced and theposition command is updated to move by a predetermined distancecorresponding to the magnitude of the applied external force.Accordingly, the feel during operation does not change. On the otherhand, when the reduction coefficient (α) is less than 1, the externalforce is reduced and the position command is updated to move by arelatively small distance when the same external force is applied.Accordingly, the feel during operation is relatively heavy.

Thus, by multiplying the current end force (Fcur) by the reductioncoefficient (α), movement in a direction toward the operation-prohibitedrange can be made difficult, and movement in a direction away from theoperation-prohibited range can be facilitated when the current positionof the monitoring point (P) is in the proximity region (R).

The degree of ease of exit (e), which is a numerical value ranging from−1 to +1 as described above, is advantageous in that the value itselfcan be used as a parameter indicating the direction in which exiting isfacilitated, or a parameter indicating the direction to guide foravoiding a collision. For example, when the degree of ease of exit (e)is positive, the current external force is simply multiplied by thedegree of ease of exit (e) so that movement in the direction away fromthe proximity region (R) is not restricted while movement in thedirection toward the operation-prohibited range is restricted.

On the other hand, since the current movement direction is a directionthat the operator desires, there may be situations where the restrictionon the movement in the direction toward the operation-prohibited rangedoes not necessarily meet the operator's desire. As described above, ifthe arm reaches the operation-prohibited range, the robot 1 stops as anerror. Therefore, reaching the operation-prohibited range should beavoided. However, even if the feel during operation is made relativelyheavy, it is assumed that movement itself is permitted, so there may besituations where the operation-prohibited range is reached.

Further, in the case of collaborative robots such as the robot 1, theoperation-allowed range tends to be smaller than that of theconventional industrial robots. For example, the range of motion of thearticulation is reduced compared to that of the conventional generalindustrial robots for safety reasons, or taking a specific posture isprohibited. Accordingly, it is assumed that there may be a risk ofunintentional movement to reach the operation-prohibited range.

It is considered that these situations also depend on the size of theproximity region (R), that is, a distance (ΔL) from the boundary. In thepresent embodiment, in order to cope with various situations, thereduction coefficient (α) can be calculated by a plurality of patternsdescribed below. Hereinafter, the patterns will be respectivelydescribed as reduction patterns A to F. While any one of these reductionpatterns A to F can be adopted, a plurality of patterns can also beadopted by changing the pattern depending on the distance between thecurrent position and the boundary.

<Reduction Pattern A: See FIG. 5>

In the reduction pattern A, when the degree of ease of exit (e) is 0 ormore, the position command is updated on the basis of the currentexternal force (Fcur). More specifically, when the degree of ease ofexit (e) is 0 or more, the reduction coefficient (α)=1 so that theconverted external force (CFcur) calculated in step S6 becomes equal tothe current external force (Fcur), that is, the external force is notreduced.

On the other hand, when the degree of ease of exit (e) is negative, thereduction coefficient (α)=k, where k is a degree of approach (k) thatbecomes 0 at the boundary and approaches 1 as it is farther away fromthe boundary, so that the converted external force (CFcur) calculated instep S6 becomes a value of the current external force (Fcur) multipliedby the degree of approach (k), that is, the external force is reduced.

In this case, as indicated by the dotted line in FIG. 5, when thecurrent external force (Fcur) is in a direction toward inside a plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the converted external force (CFcur)can be in the range that corresponds to the current external force(Fcur). Since the position command is updated on the basis of thecurrent external force (Fcur), the feel during operation does not becomeheavy in the direction moving back to the operation-allowed range fromthe proximity of the operation-prohibited range, and constantly remainslight.

Further, when the current external force (Fcur) is in a direction towardoutside the plane (e=0), which is vertical to the movement direction (S)at the time of reaching the proximity region (R), the converted externalforce (CFcur) can be in the range of the current external force (Fcur)multiplied by the degree of approach (k). Since the position command isupdated on the basis of the converted external force (CFcur), which isreduced from the current external force (Fcur), the feel duringoperation constantly remains heavy in the direction toward theoperation-prohibited range.

By making the feel during operation heavier as it is closer to theoperation-prohibited range, it is possible to physically limit themovement toward the operation-prohibited range, and inform the operatorthat the operation-prohibited range is approached.

Accordingly, the operator can avoid or carefully perform movement insuch a direction, and thus a risk of moving out of the operation-allowedrange can be reduced. Further, since movement in the direction away fromthe operation-prohibited range is not limited, it is possible to easilyexit the operation-prohibited range. Therefore, operation errors duringdirect teaching can be reduced, and the usability can be improved. Thiscontrol method is particularly effective when the distance difference(ΔL) from the boundary is large to some extent, and movement in theproximity region (R) is assumed.

<Reduction Pattern B: See FIG. 6>

In the reduction pattern B, when the degree of ease of exit (e) is 0 ormore, the position command is updated on the basis of the currentexternal force (Fcur) as with the reduction pattern A so that theexternal force is not reduced. On the other hand, when the degree ofease of exit (e) is negative, the reduction coefficient (α)=0.

In this case, as indicated by the dotted line in FIG. 6, when thecurrent external force (Fcur) is in a direction toward inside a plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the converted external force (CFcur)can be in the range that corresponds to the current external force(Fcur). On the other hand, when the current external force (Fcur) is ina direction toward outside the plane (e=0), which is vertical to themovement direction (S) at the time of reaching the proximity region (R),the converted external force (CFcur) becomes 0. Accordingly, movement insuch a direction is regulated.

By regulating movement in the direction toward the operation-prohibitedrange, it is possible to restrict the operation-prohibited range frombeing reached, and inform the operator that the movement is in adirection toward the operation-prohibited range. Accordingly, theoperator can stop the movement in such a direction, and thus moving outof the operation-allowed range can be prevented. Further, since movementin the direction away from the operation-prohibited range is notlimited, it is possible to easily exit the operation-prohibited range.Therefore, operation errors during direct teaching can be reduced, andthe usability can be improved. This control method is particularlyeffective when the distance difference (ΔL) from the boundary is small.

<Reduction Pattern C: See FIG. 7>

In the reduction pattern C, when the degree of ease of exit (e) is 0 ormore, the position command is updated on the basis of the currentexternal force (Fcur) as with the reduction pattern A so that theexternal force is not reduced.

On the other hand, when the degree of ease of exit (e) is negative, thereduction coefficient (α)=|e|·k so that the converted external force(CFcur) calculated in step S6 becomes a value of the current externalforce (Fcur) multiplied by an absolute value (|e|) of the degree of easeof exit (e) and the degree of approach (k), that is, the external forceis reduced.

In this case, as indicated by the dotted line in FIG. 7, when thecurrent external force (Fcur) is in a direction toward inside the plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the converted external force (CFcur)can be in the range that corresponds to the current external force(Fcur). On the other hand, when the current external force (Fcur) is ina direction toward outside the plane (e=0), which is vertical to themovement direction (S) at the time of reaching the proximity region (R),movement in the same direction as the movement direction (S) at the timeof reaching the proximity region (R) is permitted to some extent, andmovement is more restricted as it is farther away from the movementdirection (S).

By restricting movement in the direction toward the operation-prohibitedrange on the basis of the relationship between the movement and themovement direction (S), it is possible to permit, to some extent,movement in the movement direction (S), that is, the direction that theoperator desires, while restricting the operation-prohibited range frombeing reached by making the feel heavy. Further, since movement in thedirection away from the operation-prohibited range is not limited, it ispossible to easily exit the operation-prohibited range. Therefore,operation errors during direct teaching can be reduced, and theusability can be improved. This control method is particularly effectivewhen movement in the proximity region (R) is desired to be permitted tosome extent.

<Reduction Pattern D: See FIG. 8>

In the reduction pattern D, when the degree of ease of exit (e) is 0 ormore, the reduction coefficient (α)=e so that the converted externalforce (CFcur) calculated in step S6 becomes a value of the currentexternal force (Fcur) multiplied by the degree of ease of exit (e), andthe position command is updated on the basis of the converted externalforce (CFcur), which is reduced from the current external force (Fcur).

On the other hand, when the degree of ease of exit (e) is negative, thereduction coefficient (α)=k so that the converted external force(CFcur), which is calculated in step S6 becomes a value of the currentexternal force (Fcur) multiplied by the degree of approach (k), that is,the external force is reduced.

In this case, as indicated by the dotted line in FIG. 8, when thecurrent external force (Fcur) is in a direction toward inside the plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the position command is updated onthe basis of the current external force (Fcur) in a direction oppositeto the movement direction (S), and the position command is updated to bemore reduced as it is farther away from the direction opposite to themovement direction (S). That is, while movement in the directionopposite to the movement direction (S) is not limited, movement is morelimited as it is farther away from the direction opposite to themovement direction (S).

Further, when the current external force (Fcur) is in a direction towardoutside the plane (e=0), which is vertical to the movement direction (S)at the time of reaching the proximity region (R), the converted externalforce (CFcur) can be in the range of the current external force (Fcur)multiplied by the degree of approach (k). Since the position command isupdated on the basis of the converted external force (CFcur), which isreduced from the current external force (Fcur), the feel duringoperation constantly remains heavy in the direction toward theoperation-prohibited range.

By restricting movement in the direction toward the operation-prohibitedrange while permitting movement in the direction away from theoperation-prohibited range such that movement in the direction oppositeto the movement direction (S) at the time of reaching can be most easilyperformed, operation errors during direct teaching can be reduced, andthe usability can be improved. This control method is particularlyeffective for the case where early or urgent exiting is desired when theproximity region (R) has been reached.

<Reduction Pattern E: See FIG. 9>

In the reduction pattern E, when the degree of ease of exit (e) is 0 ormore, the reduction coefficient (α)=e so that the converted externalforce (CFcur) calculated in step S6 becomes a value of the currentexternal force (Fcur) multiplied by the degree of ease of exit (e), andthe position command is updated on the basis of the converted externalforce (CFcur), which is reduced from the current external force (Fcur).On the other hand, when the degree of ease of exit (e) is negative, thereduction coefficient (α)=0.

In this case, as indicated by the dotted line in FIG. 9, when thecurrent external force (Fcur) is in a direction toward inside the plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the position command is updated onthe basis of the current external force (Fcur) in a direction oppositeto the movement direction (S), and the position command is updated to bemore reduced as it is farther away from the direction opposite to themovement direction (S). That is, while movement in the directionopposite to the movement direction (S) is not limited, movement is morelimited as it is farther away from the direction opposite to themovement direction (S). Further, movement in the direction toward theoperation-prohibited range is regulated.

Thus, while movement in the direction toward the operation-prohibitedrange is regulated, movement in the direction away from theoperation-prohibited range is permitted such that movement in thedirection opposite to the movement direction (S) at the time of reachingcan be most easily performed. Therefore, operation errors during directteaching can be reduced, and the usability can be prevented fromdecreasing. This control method is particularly effective for the casewhere early or urgent exiting is desired when the proximity region (R)has been reached.

<Reduction Pattern F: See FIG. 10>

In the reduction pattern E, when the degree of ease of exit (e) is 0 ormore, the reduction coefficient (α)=e so that the converted externalforce (CFcur) calculated in step S6 becomes a value of the currentexternal force (Fcur) multiplied by the degree of ease of exit (e), andthe position command is updated on the basis of the converted externalforce (CFcur), which is reduced from the current external force (Fcur).

On the other hand, when the degree of ease of exit (e) is negative, thereduction coefficient (α)=|e|·k so that the converted external force(CFcur) calculated in step S6 becomes a value of the current externalforce (Fcur) multiplied by an absolute value (|e|) of the degree of easeof exit (e) and the degree of approach (k), that is, the external forceis reduced.

In this case, as indicated by the dotted line in FIG. 10, when thecurrent external force (Fcur) is in a direction toward inside the plane(e=0), which is vertical to the movement direction (S) at the time ofreaching the proximity region (R), the position command is updated onthe basis of the current external force (Fcur) in a direction oppositeto the movement direction (S), and the position command is updated to bemore reduced as it is farther away from the direction opposite to themovement direction (S). That is, while movement in the directionopposite to the movement direction (S) is not limited, movement is morelimited as it is farther away from the direction opposite to themovement direction (S).

When the current external force (Fcur) is in a direction toward outsidethe plane (e=0), which is vertical to the movement direction (S) at thetime of reaching the proximity region (R), movement in the samedirection as the movement direction (S) is permitted to some extent, andmovement is more restricted as it is farther away from the movementdirection (S).

By restricting movement in the direction toward the operation-prohibitedrange and movement in the direction away from the operation-prohibitedrange on the basis of the relationship between the movement and themovement direction (S), it is possible to permit, to some extent,movement in the movement direction (S), that is, the direction that theoperator desires, while restricting the operation-prohibited range frombeing reached by making the feel heavy. Further, it is possible topermit movement in the direction away from the operation-prohibitedrange such that movement in the direction opposite to the movementdirection (S) at the time of reaching can be most easily performed.Therefore, operation errors during direct teaching can be reduced, andthe usability can be prevented from decreasing. This control method isparticularly effective when movement in the proximity region (R) isdesired to be permitted to some extent.

Although not shown in the procedure in FIG. 3, when the current positionof the monitoring point (P) reaches the boundary of theoperation-allowed range, the position command is updated on the basis ofthe converted external force (Fcur=0) obtained by multiplying thecurrent external force (Fcur) by 0 without calculating the reductioncoefficient (α) if the current external force (Fcur) is in a directiontoward the operation-prohibited range to thereby prohibit movement insuch a direction. If it is in a direction away from the boundary, theposition command is updated on the basis of the current external force(Fcur). Accordingly, moving out of the operation-allowed range can berapidly prevented.

After calculating the reduction coefficient (α) as described above, thecontroller 2 proceeds to step S6 as shown in FIG. 3 to calculate theconverted external force (CFcur), and updates the position command onthe basis of the calculated converted external force (CFcur) (S7). Then,the controller 2 returns to step S1 and repeats the procedure to adjustthe external force required to move the monitoring point (P), that is,reduce the external force as required.

According to the control method described above, the following effectscan be achieved. The method for controlling the robot 1 includes:setting a proximity region inside a boundary of an operation-allowedrange of the robot, the proximity region being indicative of a proximityof the boundary; storing an external force applied when a monitoringpoint provided in the robot reaches the proximity region as a referenceexternal force; and comparing the reference external force with acurrent external force when a current position of the monitoring pointis in the proximity region to thereby determine a direction thatfacilitates movement away from the proximity region.

In direct teaching, an operator changes the posture of the robot bytouching the arm or other part of the robot. Since the posture of therobot can be recognized by the controller, the current position of themonitoring point provided in the robot can be specified from the currentposture of the robot. Further, in the configuration capable ofperforming direct teaching, since an external force can be detected byusing a sensing device such as a force sensor or a torque sensor, adirection and a magnitude of the applied external force can also bespecified.

In order to prevent reaching the operation-prohibited range duringdirect teaching, it is effective to limit movement in the proximityregion. On the other hand, if movement in the proximity region iscompletely restricted, movement in a direction away from the proximityregion is also restricted, which affects the usability. Therefore, inrestricting the operation-prohibited range from being reached, it isdesirable to facilitate movement in a direction away from the proximityregion.

Although a range that the arm of the robot can reach is set as theoperation-allowed range, the operation-allowed range may not necessarilybe a maximum range, but may be a range that does not interfere withperipheral devices. Therefore, when attempting to move away from theboundary closest to a current position, the arm may approach anotherboundary. That is, in order to facilitate movement away from theproximity of the operation-prohibited range, it is important todetermine in which direction moving out of the operation-allowed rangecan be prevented, that is, which direction can be used as a reference.

Therefore, an external force applied when the monitoring point reachesthe proximity region is stored as a reference external force. Then, thereference external force is compared with the current external forcewhen the current position of the monitoring point is in the proximityregion to thereby determine a direction that facilitates movement awayfrom the proximity region. Accordingly, whether the current movementdirection is a direction that should be restricted or not can bedetermined.

Further, the direction of the external force when the monitoring pointreaches the proximity region is a direction in which the monitoringpoint has so far moved. Accordingly, the movement direction indicates apath along which the monitoring position has so far moved, that is, adirection not to meet obstacles when moving away from the proximityregion. Therefore, when moving away from the proximity region, that is,the proximity of the operation-prohibited range is desired, a directionof the external force at the time of reaching the proximity region canbe used as a reference to specify a direction that does not interferewith peripheral devices, that is, a direction that facilitates exiting.

Thus, in determining the direction that facilitates movement away fromthe proximity region, it is possible to determine whether the currentmovement direction is a direction that should be restricted or not, andto specify a direction that facilitates exiting by using the directionof the external force at the time of reaching the proximity region as areference. Therefore, control can be performed, for example, to restrictmovement in the direction toward the operation-prohibited range, andpermit movement in the direction that facilitates exiting to therebyprevent the operation-prohibited range is unintentionally reached sothat teaching operation does not suspended due to an error. Accordingly,the usability in direct teaching can be improved.

In addition, since the direction of the external force at the time ofreaching the proximity region is used as a reference, there is no needto store the detailed movement positions of the monitoring point (P),and thus an excessive increase in processing load can be prevented. Thisis particularly effective in direct teaching, which is assumed toinclude a situation where the last movement path is directed from theoutside to inside of the operation-allowed range due to the operator'shand shakes or returning from a position that has slightly deviatedoutside during teaching.

Furthermore, the method for controlling the robot 1 includes:calculating an inner product of a vector of the current external forceand an inverse vector of the reference external force; and determiningthat movement is in a direction away from the operation-prohibited rangeif the calculated inner product value is 0 or more, and that movement isin a direction toward the operation-prohibited range if the calculatedinner product value is negative. The inner product of the two vectorsbecomes a positive value if the directions are the same, and becomes anegative value if the directions are opposite to each other.

Accordingly, when the inner product value of the vector of the currentexternal force and the inverse vector of the reference external force isa negative value, it indicates that the current external force is in thedirection of the reference external force, that is, the direction towardthe operation-prohibited range. On the other hand, when the innerproduct value is 0 or more, it indicates that the current external forceis not in the direction toward the operation-prohibited range.Accordingly, by using the inner product value, a direction thatfacilitates movement away from the proximity region can be easilydetermined.

Furthermore, the method for controlling the robot 1 includes:calculating a degree of ease of exit by obtaining an inner product of avector of the current external force and an inverse vector of thereference external force, in which an inner product value, which is asmallest negative value in a same direction as the reference externalforce and a largest positive value in an opposite direction to thereference external force, is taken as the degree of ease of exit. Inthis case, when the degree of ease of exit is positive, the externalforce is in a direction away from the operation-prohibited range, andwhen the degree of ease of exit is 0, the external force is not directedto the operation-prohibited range. Accordingly, there is no need torestrict movement. On the other hand, when the degree of ease of exit isnegative, the external force is in a direction toward theoperation-prohibited range. Accordingly, it is desired to restrictmovement so as not to move out of the operation-allowed range.

Accordingly, when the degree of ease of exit is 0 or more, the positioncommand is updated on the basis of the current external force so as notto restrict movement in the direction. When the degree of ease of exitis negative, the position command is updated on the basis of theconverted external force obtained by multiplying the current externalforce by a degree of approach, which becomes 0 at the boundary andapproaches 1 as it is farther away from the boundary. Thus, movement isrestricted by reducing the external force as it is closer to theboundary.

In this case, the feel in movement becomes relatively light in thedirection in which exiting is easy since the converted end force (CFcur)increases, whereas the feel in movement becomes relatively heavy in thedirection in which exiting is difficult since the converted end forcedecreases. Thus, movement in the direction toward theoperation-prohibited range can be restricted to thereby restrict theoperation-prohibited range from being reached, whereas movement in thedirection away from the operation-prohibited range can be easy. Inaddition, a direction to move, avoiding a direction toward theoperation-prohibited range, can be indicated in a manner tactile andeasily recognizable.

Furthermore, the method for controlling the robot 1 includes updatingthe position command on a basis of the current external force when thedegree of ease of exit is 0 or more so as not to limit movement in adirection away from the operation-prohibited range, and updating theposition command on a basis of a converted external force obtained bymultiplying the current external force by 0 when the degree of ease ofexit is negative so as to prohibit movement in the direction. Thus,movement in the direction toward the operation-prohibited range can beprohibited to thereby prevent the operation-prohibited range from beingreached, whereas movement in the direction away from theoperation-prohibited range can be easy.

Furthermore, the method for controlling the robot 1 includes updatingthe position command on a basis of the current external force when thedegree of ease of exit is 0 or more, and updating the position commandon a basis of a converted external force obtained by multiplying thecurrent external force by an absolute value of the degree of ease ofexit and a degree of approach, which becomes 0 at the boundary andapproaches 1 as it is farther away from the boundary, when the degree ofease of exit is negative. Thus, movement in the direction away from theoperation-prohibited range can be easy.

A direction which is the same as that of the reference external force isa direction in which the monitoring point has so far moved, and theoperator desires to move the monitoring point in the direction. In thiscase, if movement in the direction is restricted, there may be aninconvenience in teaching operation. Accordingly, the direction towardthe operation-prohibited range is permitted to some extent if it is thesame as the direction of the reference external force. The degree ofreduction of the external force is increased as the direction is fartheraway from the direction of the reference external force to therebyincrease restriction of movement. Further, the restriction of movementincreases by the degree of approach as the direction approaches theboundary.

Thus, movement is facilitated in the direction away from theoperation-prohibited range. Further, movement in the direction towardthe operation-prohibited range is permitted if it is in the samedirection as that at the time of reaching the proximity region, andpossibilities of inconvenience in teaching operation can be reduced.Since the restriction of movement is increased as the direction isfarther away from the direction at the time of reaching, it is possibleto prevent the operation-prohibited range from being unintentionallyreached.

Furthermore, the method for controlling the robot 1 includes updatingthe position command on a basis of a converted external force obtainedby multiplying the current external force by the degree of ease of exitwhen the degree of ease of exit is 0 or more, and updating the positioncommand on a basis of a converted external force obtained by multiplyingthe current external force by a degree of approach, which becomes 0 atthe boundary and approaches 1 as it is farther away from the boundary,when the degree of ease of exit is negative.

As described above, the direction of the reference external force is adirection in which the monitoring point has so far moved, and theopposite direction can be regarded as a region into which the monitoringpoint can move while avoiding contact. Accordingly, by updating theposition command on the basis of the converted external force obtainedby multiplying the current external force by the degree of ease of exit,movement in the direction opposite to that of the reference externalforce becomes least restricted, guiding to a safer path when moving awayfrom the proximity of the operation-prohibited range.

That is, since the external force is less reduced as it is closer to thedirection opposite to the direction of the external force at the time ofreaching, movement is not restricted and thus the feel is not made heavyin the direction opposite to the direction of the external force at thetime of reaching, that is, in the direction of the path in which themonitoring point has so far moved. Accordingly, the usability is notreduced, and movement away from the proximity of theoperation-prohibited range can be easy. Further, movement in thedirection toward the operation-prohibited range is more restricted bymaking the feel heavier as it is closer to the operation-prohibitedrange. Accordingly, it is possible to prevent the operation-prohibitedrange from being unintentionally reached.

Furthermore, the method for controlling the robot 1 includes updatingthe position command on a basis of a converted external force obtainedby multiplying the current external force by the degree of ease of exitwhen the degree of ease of exit is 0 or more, and updating the positioncommand on a basis of a converted external force obtained by multiplyingthe current external force by 0 when the degree of ease of exit isnegative. Accordingly, as described above, movement in the directionopposite to that of the reference external force becomes leastrestricted, guiding to a safer path when moving away from the proximityof the operation-prohibited range. Further, since movement in thedirection toward the operation-prohibited range is regulated, it ispossible to prevent the operation-prohibited range from being reached.

Furthermore, the method for controlling the robot 1 includes updatingthe position command on a basis of a converted external force obtainedby multiplying the current external force by the degree of ease of exitwhen the degree of ease of exit is 0 or more, and updating the positioncommand on a basis of a converted external force obtained by multiplyingthe current external force by an absolute value of the degree of ease ofexit and a degree of approach, which becomes 0 at the boundary andapproaches 1 as it is farther away from the boundary, when the degree ofease of exit is negative.

Accordingly, as described above, movement in the direction opposite tothat of the reference external force becomes least restricted, guidingto a safer path when moving away from the proximity of theoperation-prohibited range. In addition, the direction toward theoperation-prohibited range is permitted to some extent if it is the sameas the direction of the reference external force. Further, movement ismore restricted as it is farther away from the direction of thereference external force and closer to the boundary. Thus, it ispossible to prevent the operation-prohibited range from being reached.Moreover, the external force is more reduced and thus the feel of thearm becomes relatively heavier as the direction of the current externalforce is closer to that of the external force at the time of reaching.Accordingly, the operator can intuitively recognize that the directionis approaching the operation-prohibited range.

Furthermore, the method for controlling the robot 1 includes, when thecurrent position reaches the boundary of the operation-allowed range,updating the position command on a basis of a converted external forceobtained by multiplying the current external force by 0 when the currentexternal force is in a direction toward the operation-prohibited rangeto thereby prohibit movement in the direction, and updating the positioncommand on a basis of the current external force when the currentexternal force is in a direction away from the boundary. Accordingly,since movement in the direction toward the operation-prohibited rangecan be prohibited without calculating an inner product value, it ispossible to prevent the operation-prohibited range from being reached.

Second Embodiment

Referring to FIG. 11, a second embodiment will now be described. Amethod for controlling the robot 1 according to the second embodimentdiffers from the first embodiment in that the direction that facilitatesmovement away from the proximity region is determined on the basis of ashape of the boundary or a distance to the boundary. The configurationof the robot 1 is the same as that of the first embodiment, so the samereference numerals are used and the detailed description will beomitted.

While the proximity region (R) is in the proximity of theoperation-prohibited range, there may be a case where it is necessary tochange the posture of the robot 1 in the proximity region, that is, tomove the monitoring point (P) in the proximity region. As the currentposition changes in the proximity region (R), the direction toward theoperation-prohibited range from the current position, in other words,the direction in which exiting the proximity region (R) is easy, mayalso change.

Therefore, in the present embodiment, a virtual external force towardthe operation-prohibited range starting from the current position is setas a reference external force on the basis of the shape of the boundarywhich is closest to the current position, or the distance to theboundary. The reference external force is compared with the currentexternal force to thereby determine a direction that facilitatesmovement away from the proximity region. In this case, in order todetermine whether the direction is directed to the operation-prohibitedrange or not, the direction of the reference external force is ofimportance, and the magnitude thereof is not so important. Therefore,for example, for the magnitude of the reference external force, areference value can be set in advance or the magnitude of the currentexternal force can be used for convenience.

In this case, as shown in the distance pattern in FIG. 11, a neighborpoint (P1) is specified on the boundary closest to the current positionof the monitoring point (P) so that the direction from the currentposition toward the neighbor point (P1) is taken as the direction towardthe operation-prohibited range. Then, a virtual reference external force(vF) directed in this direction, starting from the current position, isset, and the reference external force (vF) is compared with a currentexternal force, for example, the end force (Fcur) to thereby determine adirection that facilitates movement away from the proximity region. Inthis case, the current movement direction can be determined by obtainingthe inner product of the end force (Fcur) and the reference externalforce (vF) as in the first embodiment. However, the current movementdirection can also be determined by methods other than obtaining theinner product.

Thus, by determining the current movement direction on the basis of thecurrent position of the monitoring point (P) and the neighbor point(P1), that is, the distance between the current position and theboundary, it is possible, as with the first embodiment, to specifywhether the current movement direction is a direction that should berestricted or not, and to specify a direction that facilitates exiting.

Alternatively, as shown in the shape pattern in FIG. 11, in the casewhere the closest boundary is formed by a flat surface such as a wall, adirection, for example, vertical to the flat surface, starting from thecurrent position, is set as a direction toward the operation-prohibitedrange. On the basis of the reference external force (vF) directed inthis direction, the direction that facilitates exiting from theproximity region can be determined to thereby specify whether thecurrent movement direction is a direction that should be restricted ornot, and specify a direction that facilitates exiting.

Therefore, as with the first embodiment, control can be performed torestrict movement in the direction toward the operation-prohibitedrange, and permit movement in the direction that facilitates exiting.Accordingly, the usability during direct teaching can be improved.Further, even if the current position of the monitoring point (P)changes in the proximity region (R), it is possible to specify themovement direction that should be restricted and the direction thatfacilitates exiting in accordance with the change.

In this case, any of the reduction patterns A to F described in thefirst embodiment can also be combined. For example, by using the virtualreference external force (vF) instead of the end force in reaching(Finc) described in the first embodiment, the same advantageous effectsas those of the reduction patterns A to F described in the firstembodiment can be achieved in the control method of the presentembodiment.

Third Embodiment

Referring to FIG. 12, a third embodiment will now be described. A methodfor controlling the robot 1 according to the third embodiment differsfrom the first embodiment in that the direction that facilitatesmovement away from the proximity region is determined on the basis of avirtual external force which is directed from the origin of the robot tothe current position. The configuration of the robot 1 is the same asthat of the first embodiment, so the same reference numerals are usedand the detailed description will be omitted.

While the proximity region (R) is in the proximity of theoperation-prohibited range, there may be a case where it is necessary tochange the posture of the robot 1 in the proximity region, that is, tomove the monitoring point (P) in the proximity region. As the currentposition changes in the proximity region (R), the direction toward theoperation-prohibited range from the current position, in other words,the direction in which exiting the proximity region (R) is easy, mayalso change.

In addition, the operation-allowed range may be set as a range that thearm of the robot can reach. Therefore, a situation can be assumed wherethe robot arm is fully extended at the boundary of the operation-allowedrange. In other words, the direction in which the robot arm is retractedcan be regarded as the direction in which it exits theoperation-prohibited range. For example, if the robot arm has a reachlimit, the direction toward the origin (O) of the robot is taken as thedirection in which the arm is retracted, which is the direction in whichexiting is easiest.

Therefore, in the present embodiment, a virtual external force, startingfrom the current position of the monitoring point (P) provided in therobot 1, in the direction from the origin (O) of the robot toward thecurrent position is set as the reference external force (vF). Thereference external force is compared with the current external force tothereby determine a direction that facilitates movement away from theproximity region. In this case, in order to determine whether thedirection is directed to the operation-prohibited range or not, thedirection of the reference external force is of importance, and themagnitude thereof is not so important. Therefore, for example, for themagnitude of the reference external force, a reference value can be setin advance or the magnitude of the current external force can be usedfor convenience.

In this case, as shown in FIG. 12, a virtual line (vL) that passesthrough the current position of the monitoring point (P) and the originis set, and a direction, starting from the current position, in adirection along the virtual line (vL) toward outside the currentposition is taken as the direction toward the operation-prohibitedrange. Accordingly, a virtual reference external force (vF) directed inthis direction, starting from the current position, is set, and thereference external force (vF) is compared with a current external force,for example, the end force (Fcur) to thereby determine a direction thatfacilitates movement away from the proximity region. In this case, thecurrent movement direction can be determined by obtaining the innerproduct of the end force (Fcur) and the reference external force (vF) asin the first embodiment. However, the current movement direction canalso be determined by methods other than obtaining the inner product.

Thus, on the basis of the reference external force (vF) directed alongthe virtual line (vL) that passes the current position and the origin(O), starting from the current position, the direction that facilitatesexiting from the proximity region can be determined to thereby specifywhether the current movement direction is a direction that should berestricted or not, and specify a direction that facilitates exiting.Therefore, control can be performed, for example, to restrict movementin the direction toward the operation-prohibited range, and permitmovement in the direction that facilitates exiting to thereby improveusability during direct teaching.

Therefore, as with the first embodiment, control can be performed torestrict movement in the direction toward the operation-prohibitedrange, and permit movement in the direction that facilitates exiting.Accordingly, the usability during direct teaching can be improved.Further, even if the current position of the monitoring point (P)changes in the proximity region (R), it is possible to specify themovement direction that should be restricted and the direction thatfacilitates exiting in accordance with the change.

In this case, any of the reduction patterns A to F described in thefirst embodiment can also be combined. For example, by using the virtualreference external force (vF) instead of the end force in reaching(Finc) described in the first embodiment, the same advantageous effectsas those of the reduction patterns A to F described in the firstembodiment can be achieved in the control method of the presentembodiment.

Fourth Embodiment

Referring to FIG. 13, a fourth embodiment will now be described. Amethod for controlling the robot 1 according to the fourth embodimentdiffers from the first embodiment in that the direction that facilitatesmovement away from the proximity region is determined on the basis of adistance to the boundary in the case where the current position isassumed to have been displaced. The configuration of the robot 1 is thesame as that of the first embodiment, so the same reference numerals areused and the detailed description will be omitted.

While the proximity region (R) is in the proximity of theoperation-prohibited range, there may be a case where it is necessary tochange the posture of the robot, that is, to move the monitoring point(P) in the proximity region (R). As the current position changes in theproximity region (R), the direction toward the operation-prohibitedrange from the current position, in other words, the direction in whichexiting the proximity region (R) is easy, may also change.

Therefore, in the present embodiment, among virtual positions (vP)displaced from the current position of the monitoring point (P) providedin the robot 1 by a predetermined distance, a position closest to theboundary is set as a closest approach position (vP), a virtual externalforce, starting from the current position of the monitoring point (P),in the direction from the current position toward the closest approachposition (vP) is set as the reference external force (vF). The referenceexternal force is compared with the current external force to therebydetermine a direction that facilitates movement away from the proximityregion. In this case, in order to determine whether the direction isdirected to the operation-prohibited range or not, the direction of thereference external force is of importance, and the magnitude thereof isnot so important. Therefore, for example, for the magnitude of thereference external force, a reference value can be set in advance or themagnitude of the current external force can be used for convenience.

Specifically, as shown in FIG. 13, a virtual circle (vC) is set aboutthe center of the current position, and a plurality of virtual positions(vP0 to vPn) are set on the virtual circle (vC). Among the virtualpositions (vP0 to vPn), the virtual position (vP0), for example, whichis closest to the boundary is specified as a closest approach position.This is because movement from the current position of the monitoringpoint (P) toward the closest approach position is most likely to bedirected to the operation-prohibited range.

Then, a virtual reference external force (vF), starting from the currentposition, in the direction toward the closest approach position is set.The reference external force is compared with the current external forceto thereby determine a direction that facilitates movement away from theproximity region, and specify a direction that tends to allow movementout of the operation-allowed range, that is, the direction that shouldbe restricted, and specify a direction that facilitates exiting.

Therefore, as with the first embodiment, control can be performed torestrict movement in the direction toward the operation-prohibitedrange, and permit movement in the direction that facilitates exiting.Accordingly, the usability during direct teaching can be improved.Further, even if the current position of the monitoring point (P)changes in the proximity region (R), it is possible to specify themovement direction that should be restricted and the direction thatfacilitates exiting in accordance with the change.

In this case, any of the reduction patterns A to F described in thefirst embodiment can also be combined. For example, by using the virtualreference external force (vF) instead of the end force in reaching(Finc) described in the first embodiment, the same advantageous effectsas those of the reduction patterns A to F described in the firstembodiment can be achieved in the control method of the presentembodiment.

OTHER EMBODIMENTS

In the embodiments described above, the center position of the flange 1g is set as the monitoring point (P) of the robot 1. However, themonitoring point (P) of the robot 1 is not limited to the centerposition of the flange 1 g, and may be provided at any position in thearm or the tool 3. The shape of the robot 1 and the outline of the armare mechanically fixed, and the shape of the tool 3 for use in work canalso be specified in advance. If the shape can be mechanically fixed,the monitoring point (P) set at a desired position can be specified onthe basis of the posture of the robot 1.

Therefore, even if the monitoring point (P) is set at a desiredposition, the current position and the applied external force can bespecified, and the control method described above can be used to controlthe robot 1. That is, the monitoring point (P) for monitoring intrusioninto the operation-prohibited range can be provided at any position(shoulder, elbow, etc.) in addition to the end portion. When the endposition is moved according to the end force, link positions aredetermined in the process of calculating an articulation angle from atarget position (inverse kinematics calculation). Accordingly, themonitoring position, which moves along with the end portion, can beobtained by setting the monitoring position as a position in the linkcoordinate system in advance. For example, setting a monitoring site ata raised portion of the robot can contribute to prevention of collisionwith obstacles around the robot.

Moreover, a controller such as the controller 2 that can implement thecontrol method described above can be used to control the robot 1 tothereby prevent reduction in usability during direct teaching.

In the embodiments described above, the current position of themonitoring point (P) is specified by the six dimensional coordinatesystem. However, other coordinate systems can also be used withparameters that uniquely specify the current position of the monitoringpoint (P), the posture and the operation-allowed range of the robot 1.For example, the operation-allowed range can be defined by settinglimits such as an upper limit by software using T-parameters orJ-parameters.

Throughout the drawings, a reference numeral 1 indicates the robot and areference numeral 2 indicates the controller (control apparatus)provided with the CPU 2A.

What is claimed is:
 1. A method for controlling a robot, in which directteaching is performed while updating a position command on a basis of anapplied external force, the method comprising steps of: setting aproximity region inside a boundary of an operation-allowed range of therobot, the proximity region being indicative of a proximity of theboundary; storing an external force applied when a monitoring pointprovided in the robot reaches the proximity region as a referenceexternal force; and comparing the reference external force with acurrent external force when a current position of the monitoring pointis in the proximity region to thereby determine a direction thatfacilitates movement away from the proximity region.
 2. A method forcontrolling a robot, in which direct teaching is performed whileupdating a position command on a basis of an applied external force, themethod comprising steps of: setting a proximity region inside a boundaryof an operation-allowed range of the robot, the proximity region beingindicative of a proximity of the boundary; setting a virtual externalforce toward the operation-prohibited range starting from a currentposition as a reference external force on a basis of a shape of aboundary which is closest to a current position of a monitoring pointprovided in the robot, or a distance to the boundary; and comparing thereference external force with a current external force when a currentposition of the monitoring point is in the proximity region to therebydetermine a direction that facilitates movement away from the proximityregion.
 3. A method for controlling a robot, in which direct teaching isperformed while updating a position command on a basis of an appliedexternal force, the method comprising steps of: setting a proximityregion inside a boundary of an operation-allowed range of the robot, theproximity region being indicative of a proximity of the boundary;setting a virtual external force, starting from a current position of amonitoring point provided in the robot, in a direction from an origin ofthe robot toward the current position as a reference external force; andcomparing the reference external force with a current external forcewhen a current position of the monitoring point is in the proximityregion to thereby determine a direction that facilitates movement awayfrom the proximity region.
 4. A method for controlling a robot, in whichdirect teaching is performed while updating a position command on abasis of an applied external force, the method comprising steps of:setting a proximity region inside a boundary of an operation-allowedrange of the robot, the proximity region being indicative of a proximityof the boundary; setting a position closest to the boundary, amongvirtual positions displaced from a current position of a monitoringpoint provided in the robot by a predetermined distance, as a closestapproach position; setting a virtual external force, starting from acurrent position of the monitoring point, in a direction from thecurrent position toward the closest approach position as a referenceexternal force; and comparing the reference external force with acurrent external force when a current position of the monitoring pointis in the proximity region to thereby determine a direction thatfacilitates movement away from the proximity region.
 5. The method forcontrolling a robot according to claim 1, further comprising:calculating an inner product of a vector of the current external forceand an inverse vector of the reference external force; and determiningthat movement is in a direction away from the operation-prohibited rangeif the calculated inner product value is 0 or more, and that movement isin a direction toward the operation-prohibited range if the calculatedinner product value is negative.
 6. The method for controlling a robotaccording to claim 1, further comprising: calculating a degree of easeof exit by obtaining an inner product of a vector of the currentexternal force and an inverse vector of the reference external force, inwhich an inner product value, which is a smallest negative value in asame direction as the reference external force and a largest positivevalue in an opposite direction to the reference external force, is takenas the degree of ease of exit; and updating the position command on abasis of the current external force when the degree of ease of exit is 0or more, and updating the position command on a basis of a convertedexternal force obtained by multiplying the current external force by adegree of approach, which becomes 0 at the boundary and approaches 1 asit is farther away from the boundary, when the degree of ease of exit isnegative.
 7. The method for controlling a robot according to claim 1,further comprising: calculating a degree of ease of exit by obtaining aninner product of a vector of the current external force and an inversevector of the reference external force, in which an inner product value,which is a smallest negative value in a same direction as the referenceexternal force and a largest positive value in an opposite direction tothe reference external force, is taken as the degree of ease of exit;and updating the position command on a basis of the current externalforce when the degree of ease of exit is 0 or more, and updating theposition command on a basis of a converted external force obtained bymultiplying the current external force by 0 when the degree of ease ofexit is negative.
 8. The method for controlling a robot according toclaim 1, further comprising: calculating a degree of ease of exit byobtaining an inner product of a vector of the current external force andan inverse vector of the reference external force, in which an innerproduct value, which is a smallest negative value in a same direction asthe reference external force and a largest positive value in an oppositedirection to the reference external force, is taken as the degree ofease of exit; and updating the position command on a basis of thecurrent external force when the degree of ease of exit is 0 or more, andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by an absolute valueof the degree of ease of exit and a degree of approach, which becomes 0at the boundary and approaches 1 as it is farther away from theboundary, when the degree of ease of exit is negative.
 9. The method forcontrolling a robot according to claim 1, further comprising:calculating a degree of ease of exit by obtaining an inner product of avector of the current external force and an inverse vector of thereference external force, in which an inner product value, which is asmallest negative value in a same direction as the reference externalforce and a largest positive value in an opposite direction to thereference external force, is taken as the degree of ease of exit; andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by the degree of easeof exit when the degree of ease of exit is 0 or more, and updating theposition command on a basis of a converted external force obtained bymultiplying the current external force by a degree of approach, whichbecomes 0 at the boundary and approaches 1 as it is farther away fromthe boundary, when the degree of ease of exit is negative.
 10. Themethod for controlling a robot according to claim 1, further comprising:calculating a degree of ease of exit by obtaining an inner product of avector of the current external force and an inverse vector of thereference external force, in which an inner product value, which is asmallest negative value in a same direction as the reference externalforce and a largest positive value in an opposite direction to thereference external force, is taken as the degree of ease of exit; andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by the degree of easeof exit when the degree of ease of exit is 0 or more, and updating theposition command on a basis of a converted external force obtained bymultiplying the current external force by 0 when the degree of ease ofexit is negative.
 11. The method for controlling a robot according toclaim 1, further comprising: calculating a degree of ease of exit byobtaining an inner product of a vector of the current external force andan inverse vector of the reference external force, in which an innerproduct value, which is a smallest negative value in a same direction asthe reference external force and a largest positive value in an oppositedirection to the reference external force, is taken as the degree ofease of exit; and updating the position command on a basis of aconverted external force obtained by multiplying the current externalforce by the degree of ease of exit when the degree of ease of exit is 0or more, and updating the position command on a basis of a convertedexternal force obtained by multiplying the current external force by anabsolute value of the degree of ease of exit and a degree of approach,which becomes 0 at the boundary and approaches 1 as it is farther awayfrom the boundary, when the degree of ease of exit is negative.
 12. Themethod for controlling a robot according to claim 1, further comprising,when the current position reaches the boundary of the operation-allowedrange, updating the position command on a basis of a converted externalforce obtained by multiplying the current external force by 0 when thecurrent external force is in a direction toward the operation-prohibitedrange to thereby prohibit movement in the direction, and updating theposition command on a basis of the current external force when thecurrent external force is in a direction away from the boundary.
 13. Themethod for controlling a robot according to claim 2, further comprising:calculating an inner product of a vector of the current external forceand an inverse vector of the reference external force; and determiningthat movement is in a direction away from the operation-prohibited rangeif the calculated inner product value is 0 or more, and that movement isin a direction toward the operation-prohibited range if the calculatedinner product value is negative.
 14. The method for controlling a robotaccording to claim 2, further comprising: calculating a degree of easeof exit by obtaining an inner product of a vector of the currentexternal force and an inverse vector of the reference external force, inwhich an inner product value, which is a smallest negative value in asame direction as the reference external force and a largest positivevalue in an opposite direction to the reference external force, is takenas the degree of ease of exit; and updating the position command on abasis of the current external force when the degree of ease of exit is 0or more, and updating the position command on a basis of a convertedexternal force obtained by multiplying the current external force by adegree of approach, which becomes 0 at the boundary and approaches 1 asit is farther away from the boundary, when the degree of ease of exit isnegative.
 15. The method for controlling a robot according to claim 2,further comprising: calculating a degree of ease of exit by obtaining aninner product of a vector of the current external force and an inversevector of the reference external force, in which an inner product value,which is a smallest negative value in a same direction as the referenceexternal force and a largest positive value in an opposite direction tothe reference external force, is taken as the degree of ease of exit;and updating the position command on a basis of the current externalforce when the degree of ease of exit is 0 or more, and updating theposition command on a basis of a converted external force obtained bymultiplying the current external force by 0 when the degree of ease ofexit is negative.
 16. The method for controlling a robot according toclaim 2, further comprising: calculating a degree of ease of exit byobtaining an inner product of a vector of the current external force andan inverse vector of the reference external force, in which an innerproduct value, which is a smallest negative value in a same direction asthe reference external force and a largest positive value in an oppositedirection to the reference external force, is taken as the degree ofease of exit; and updating the position command on a basis of thecurrent external force when the degree of ease of exit is 0 or more, andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by an absolute valueof the degree of ease of exit and a degree of approach, which becomes 0at the boundary and approaches 1 as it is farther away from theboundary, when the degree of ease of exit is negative.
 17. An apparatusfor controlling a robot, in which direct teaching is performed whileupdating a position command on a basis of an applied external force,comprising: a non-transitory computer-readable recording medium in whicha computer program is stored in advance; and a calculation unitconfigured to read the computer program from the recording medium and toperform, in accordance with the read computer program, a processincluding steps of: setting a proximity region inside a boundary of anoperation-allowed range of the robot, the proximity region beingindicative of a proximity of the boundary; storing an external forceapplied when a monitoring point provided in the robot reaches theproximity region as a reference external force; and comparing thereference external force with a current external force when a currentposition of the monitoring point is in the proximity region to therebydetermine a direction that facilitates movement away from the proximityregion.
 18. The apparatus for controlling a robot according to claim 13,the process further including: calculating an inner product of a vectorof the current external force and an inverse vector of the referenceexternal force; and determining that movement is in a direction awayfrom the operation-prohibited range if the calculated inner productvalue is 0 or more, and that movement is in a direction toward theoperation-prohibited range if the calculated inner product value isnegative.
 19. The method for controlling a robot according to claim 17,the process further including: calculating a degree of ease of exit byobtaining an inner product of a vector of the current external force andan inverse vector of the reference external force, in which an innerproduct value, which is a smallest negative value in a same direction asthe reference external force and a largest positive value in an oppositedirection to the reference external force, is taken as the degree ofease of exit; and updating the position command on a basis of thecurrent external force when the degree of ease of exit is 0 or more, andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by a degree ofapproach, which becomes 0 at the boundary and approaches 1 as it isfarther away from the boundary, when the degree of ease of exit isnegative.
 20. The apparatus for controlling a robot according to claim17, the process further including: calculating a degree of ease of exitby obtaining an inner product of a vector of the current external forceand an inverse vector of the reference external force, in which an innerproduct value, which is a smallest negative value in a same direction asthe reference external force and a largest positive value in an oppositedirection to the reference external force, is taken as the degree ofease of exit; and updating the position command on a basis of thecurrent external force when the degree of ease of exit is 0 or more, andupdating the position command on a basis of a converted external forceobtained by multiplying the current external force by 0 when the degreeof ease of exit is negative.